/*
 * Component.h
 *
 *  Created on: 29-06-2013
 *      Author: Jarek
 */

#ifndef COMPONENT_H_
#define COMPONENT_H_

#include "BoundingBox.h"
#include "Input.h"
#include "ETime.h"

class Component
{
protected:
	Component*			parent;
	Component**			children;
	uint				childrenCount;

	BoundingBox			drawBox;
	BoundingBox			logicBox;
	bool				initialized;
	uint				id;
	int 				depth;
	bool				active;
	bool				visible;

	enum COMPONENT_TYPE
	{
		COMPONENT_TYPE_MENU = 0,
		COMPONENT_TYPE_IMAGE_BOX,
		COMPONENT_TYPE_BUTTON,


		COMPONENT_TYPE_MAX
	}componentType;
protected:
	bool					contains(int x, int y);
public:
	Component();
	virtual ~Component();

	virtual void			onInitialize(uint id, uint childrenCaunt = 0, Component** children = NULL);
	virtual	void			onDestroy();
	virtual void			onRun(const ETime& time);
	virtual void			onDraw(const ETime& time);
	virtual bool 			handleInput(const ETime& time, const Input& input);
	virtual BoundingBox		getAbsoluteDrawBox();
	virtual BoundingBox		getAbsoluteLogicBox	();

	inline void				setActive(bool active) { this->active = active; }
	inline void				setVisible(bool visible) { this->visible = visible; }


	inline bool				getActive() { return active; }
	inline bool				getVisible() { return visible; }
	inline Component*   	getChild(uint id) { return children[id]; }
};

#endif /* COMPONENT_H_ */
